package com.jiejie.university.service.impl;

import com.jiejie.university.entity.Student;
import com.jiejie.university.mapper.StudentMapper;
import com.jiejie.university.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentServiceImpl implements StudentService {
    @Autowired
    private StudentMapper studentMapper;
    @Override
    public List<Student> findStudentAll() {
        return studentMapper.selectStudentAll();
    }

    @Override
    public Student findStudentById(Integer id) {
        Student student = studentMapper.selectStudentById(id);
        return student;
    }

    @Override
    public int addStudent(Student student) {
        int i = studentMapper.insertStudent(student);
        if(i>0)
            return 200;
            else
        return 0;
    }

    @Override
    public int deleteStudent(Integer id) {
        int i = studentMapper.deleteStudentById(id);
        if(i>0)
            return 200;
        else
            return 0;
    }

    @Override
    public int updataStudent(Student student) {
        int i = studentMapper.updateStudentById(student);
        if(i>0)
            return 200;
        else
            return 0;
    }
}
